<?php
namespace app\admin2\validate;

use think\Validate;

class Csuser extends Validate
{
    protected $rule = [
        'username' => 'require|unique:csuser',
        'username' => ['regex' => '^\w+$'],
        'password' => 'require|confirm:confirm_password',
        'confirm_password' => 'require|confirm:password',
    ];

    protected $message = [
        'username.unique'  => '账号已存在',
        'username.require' => '请输入用户名',
        'username.regex'   => '用户名不能含中文及特殊字符',
        'password.confirm' => '两次输入密码不一致',
        'confirm_password.confirm' => '两次输入密码不一致',
        // 'password.between' => '密码长度4-13之间',
    ];

    protected $scene = [
        'edit' => ['username.unique'=>'require|unique:User,username^id','password' => 'confirm:confirm_password','confirm_password' => 'confirm:password'],
    ];

}